const WXAPI = require('../../utils/apifm-ttapi')
const app = getApp();
const WxParse = require('../../wxParse/wxParse.js');
const ApifmShare = require('../../template/share/index.js');
const CONFIG = require('../../config.js')
const AUTH = require('../../utils/auth')
const SelectSizePrefix = "选择："

let videoAd = null; // 视频激励广告

Page({
  data: {
    id:'',
    bookDetail:null,
    likeBook:[]
  },
  async onLoad(e) {
    this.setData({
      id: e.id
    })
    this.getBookDetail()
  },
  async getBookDetail() {
    
    wx.showLoading({
      "mask": true
    })
    const res = await WXAPI.getBookDetail({
      id:this.data.id,
    })
    console.log(res,999);
    wx.hideLoading()
    this.setData({
      bookDetail: res.bookDetail,
      likeBook:res.likeBook
    });
  },
  onShow (){
    
  },
  startRead(){
     wx.navigateTo({
      url: "/pages/read-book/index?id="+this.data.id
    })
  },
  async addBookTocollect(){
    const res = await WXAPI.addCollect({
      bookId:this.data.id,
    })
    if (res.code === 0){
      wx.showToast({
        title: '添加成功',
        icon: 'success'
      })
    }      
  }
})
